home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / csim / source.lha / source / Threads / GnuThreads / queue.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-14  |  1.3 KB  |  49 lines

  1. /*
  2.  * queue.c -- queue manipulation routines.
  3.  * Copyright (C) 1991 Stephen Crane.
  4.  *
  5.  * This is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 1, or (at your option)
  8.  * any later version.
  9.  *
  10.  * This software is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * see the file COPYING.  If not, write to
  17.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  * author: Stephen Crane, (jsc@doc.ic.ac.uk), Department of Computing,
  20.  * Imperial College of Science, Technology and Medicine, 180 Queen's
  21.  * Gate, London SW7 2BZ, England.
  22.  */
  23. #include "gnulwp.h"
  24.  
  25. /*
  26.  * hoq -- remove the head of the queue and return it
  27.  */
  28. struct pcb *hoq (struct lpq *q)
  29. {
  30.     struct pcb *head;
  31.  
  32.     if ((head=q->head) && !(q->head=head->next))
  33.         q->tail = 0;
  34.     return (head);
  35. }
  36.  
  37. /*
  38.  * toq -- add element to the tail of the queue
  39.  */
  40. void toq (struct lpq *q, struct pcb *p)
  41. {
  42.     if (!q->tail)
  43.         q->head = p;
  44.     else
  45.         q->tail->next = p;
  46.     q->tail = p;
  47.     p->next = 0;
  48. }
  49.